package leetcode.simple.q1313;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution {
    static int[] nums = {1, 2, 3, 4};
    List<Integer> newNums = new ArrayList<Integer>();

    int a = 0, b = 0;
    public int[] decompressRLElist(int[] nums) {

        for (int i = 0; i < nums.length; i++) {
            if (2 * i >= nums.length){
                break;
            }
            a = nums[2 * i];
            b = nums[2 * i + 1];
            for (int j = 0; j < a; j++) {
                newNums.add(b);
            }
        }
        int index = 0;
        for (int num : newNums) {
            nums[index++] = num;
        }

        return nums;
    }

    public static void main(String[] args) {
        Solution s = new Solution();
        int[] n = s.decompressRLElist(nums);
        System.out.println(Arrays.toString(n));
    }
}
